********************************************************************************
** LOAD DATA
********************************************************************************

use "flanders_data.dta", clear

label drop _all

********************************************************************************
** PROBABILITY OF BEING IN GOVERNMENT: EXPECTATIONS
********************************************************************************

* Ordinary least squares regression models
eststo GE1: reg govt_pvda i.party_pvda##i.type##i.survey i.sex age 
eststo GE2: reg govt_groen i.party_groen##i.type##i.survey i.sex age
eststo GE3: reg govt_vooruit i.party_vooruit##i.type##i.survey i.sex age
eststo GE4: reg govt_cdv i.party_cdv##i.type##i.survey i.sex age
eststo GE5: reg govt_ovld i.party_ovld##i.type##i.survey i.sex age
eststo GE6: reg govt_nva i.party_nva##i.type##i.survey i.sex age
eststo GE7: reg govt_vb i.party_vb##i.type##i.survey i.sex age

* Regression table
esttab GE1 GE2 GE3 GE4 GE5 GE6 GE7 using "govt_exp_models.tex", substitute({table} {table*} \begin{tabular*} \footnotesize\begin{tabular*}) wide nonumbers drop(1.party_pvda 1.party_groen 1.party_vooruit 1.party_ovld 1.party_cdv 1.party_nva 1.party_vb 1.sex 1.party_pvda#1.type 1.party_pvda#2.type 1.party_pvda#1.type#1.survey 1.party_pvda#1.type#2.survey 1.party_pvda#2.type#1.survey 1.party_pvda#2.type#2.survey 1.party_groen#1.type 1.party_groen#2.type 1.party_groen#1.type#1.survey 1.party_groen#1.type#2.survey  1.party_groen#2.type#1.survey 1.party_groen#2.type#2.survey 1.party_vooruit#1.type 1.party_vooruit#2.type 1.party_vooruit#1.type#1.survey 1.party_vooruit#1.type#2.survey 1.party_vooruit#2.type#1.survey 1.party_vooruit#2.type#2.survey 1.party_cdv#1.type 1.party_cdv#2.type 1.party_cdv#1.type#1.survey 1.party_cdv#1.type#2.survey 1.party_cdv#2.type#1.survey 1.party_cdv#2.type#2.survey 1.party_ovld#1.type 1.party_ovld#2.type 1.party_ovld#1.type#1.survey 1.party_ovld#1.type#2.survey 1.party_ovld#2.type#1.survey 1.party_ovld#2.type#2.survey 1.party_nva#1.type 1.party_nva#2.type 1.party_nva#1.type#1.survey 1.party_nva#1.type#2.survey 1.party_nva#2.type#1.survey 1.party_nva#2.type#2.survey 1.party_vb#1.type 1.party_vb#2.type 1.party_vb#1.type#1.survey 1.party_vb#1.type#2.survey 1.party_vb#2.type#1.survey 1.party_vb#2.type#2.survey 2.party_pvda#1.type#1.survey 2.party_pvda#1.type#2.survey 2.party_pvda#2.type#1.survey 2.party_groen#1.type#1.survey 2.party_groen#1.type#2.survey 2.party_groen#2.type#1.survey 2.party_vooruit#1.type#1.survey 2.party_vooruit#1.type#2.survey 2.party_vooruit#2.type#1.survey 2.party_cdv#1.type#1.survey 2.party_cdv#1.type#2.survey 2.party_cdv#2.type#1.survey 2.party_ovld#1.type#1.survey 2.party_ovld#1.type#2.survey 2.party_ovld#2.type#1.survey 2.party_nva#1.type#1.survey 2.party_nva#1.type#2.survey 2.party_nva#2.type#1.survey 2.party_vb#1.type#1.survey 2.party_vb#1.type#2.survey 2.party_vb#2.type#1.survey 1.party_pvda#2.survey 2.party_pvda#1.survey 1.party_groen#2.survey 2.party_groen#1.survey 1.party_vooruit#2.survey 2.party_vooruit#1.survey 1.party_cdv#2.survey 2.party_cdv#1.survey 1.party_ovld#2.survey 2.party_ovld#1.survey 1.party_nva#2.survey 2.party_nva#1.survey 1.party_vb#2.survey 2.party_vb#1.survey 2.party_pvda#1.type 2.party_groen#1.type 2.party_vooruit#1.type 2.party_cdv#1.type 2.party_ovld#1.type 2.party_nva#1.type 2.party_vb#1.type 1.party_pvda#1.survey 1.party_vooruit#1.survey 1.party_groen#1.survey 1.party_cdv#1.survey 1.party_ovld#1.survey 1.party_nva#1.survey 1.party_vb#1.survey 1.type#1.survey 1.type#2.survey 2.type#1.survey) refcat(2.party_pvda "\textbf{Party preference}" 1.type "\textbf{Respondents}" 2.sex "\textbf{Sociodemographics}" 1.survey "\textbf{Survey}" 2.party_pvda#2.type "\textbf{Two-way interactions I}" 2.party_pvda#2.survey "\textbf{Two-way interactions II}" 2.type#2.survey "\textbf{Two-way interactions III}" 2.party_pvda#2.type#2.survey "\textbf{Three-way interactions}", nolabel) width(\hsize) b(2) se(2) star(* 0.05) label mtitles("PVDA" "Groen" "Vooruit" "CD\&V" "Open VLD" "N-VA" "VB") interaction("$\times$") style(tex) replace booktabs varlabels(_cons "\textbf{Constant}" 1.type "\hspace{1em} Citizens (R)" 2.type "\hspace{1em} Politicians" 2.party_pvda "\hspace{1em} PVDA" 2.party_groen "\hspace{1em} Groen" 2.party_vooruit "\hspace{1em} Vooruit" 2.party_ovld "\hspace{1em} Open Vld" 2.party_cdv "\hspace{1em} CD\&V" 2.party_nva "\hspace{1em} N-VA" 2.party_vb "\hspace{1em} VB" 2.party_pvda#2.type "\hspace{1em} PVDA $\times$ Politicians" 2.party_groen#2.type "\hspace{1em} Groen $\times$ Politicians" 2.party_vooruit#2.type "\hspace{1em} Vooruit $\times$ Politicians" 2.party_ovld#2.type "\hspace{1em} Open Vld $\times$ Politicians" 2.party_cdv#2.type "\hspace{1em} CD\&V $\times$ Politicians" 2.party_nva#2.type "\hspace{1em} N-VA $\times$ Politicians" 2.party_vb#2.type "\hspace{1em} VB $\times$ Politicians" 2.sex "\hspace{1em} Male" age "\hspace{1em} Age" 1.survey "\hspace{1em} 2023 survey (R)" 2.survey "\hspace{1em} 2024 survey" 2.type#2.survey "\hspace{1em} Politicians $\times$ 2024 survey" 2.party_pvda#2.survey "\hspace{1em} PVDA $\times$ 2024 survey" 2.party_groen#2.survey "\hspace{1em} Groen $\times$ 2024 survey" 2.party_vooruit#2.survey "\hspace{1em} Vooruit $\times$ 2024 survey" 2.party_cdv#2.survey "\hspace{1em} CD\&V $\times$ 2024 survey" 2.party_ovld#2.survey "\hspace{1em} Open Vld $\times$ 2024 survey" 2.party_nva#2.survey "\hspace{1em} N-VA $\times$ 2024 survey" 2.party_vb#2.survey "\hspace{1em} VB $\times$ 2024 survey" 2.party_pvda#2.type#2.survey "\hspace{1em} PVDA $\times$ Politicians $\times$ 2024 survey" 2.party_groen#2.type#2.survey "\hspace{1em} Groen $\times$ Politicians $\times$ 2024 survey" 2.party_vooruit#2.type#2.survey "\hspace{1em} Vooruit $\times$ Politicians $\times$ 2024 survey" 2.party_cdv#2.type#2.survey "\hspace{1em} CD\&V $\times$ Politicians $\times$ 2024 survey" 2.party_ovld#2.type#2.survey "\hspace{1em} Open Vld $\times$ Politicians $\times$ 2024 survey" 2.party_nva#2.type#2.survey "\hspace{1em} N-VA $\times$ Politicians $\times$ 2024 survey" 2.party_vb#2.type#2.survey "\hspace{1em} VB $\times$ Politicians $\times$ 2024 survey") title("OLS Regression Results for Citizens' and Politicians' Expectations, Probability of Being in Government"\label{govt_exp_models}) order(1.type 2.type 2.party_pvda 2.party_groen 2.party_vooruit 2.party_cdv 2.party_ovld 2.party_nva 2.party_vb 2.party_pvda#2.type 2.party_groen#2.type 2.party_vooruit#2.type 2.party_cdv#2.type 2.party_ovld#2.type 2.party_nva#2.type 2.party_vb#2.type 2.party_pvda#2.survey 2.party_groen#2.survey 2.party_vooruit#2.survey 2.party_cdv#2.survey 2.party_ovld#2.survey 2.party_nva#2.survey 2.party_vb#2.survey 2.type#2.survey 2.party_pvda#2.type#2.survey 2.party_groen#2.type#2.survey 2.party_vooruit#2.type#2.survey 2.party_cdv#2.type#2.survey 2.party_ovld#2.type#2.survey 2.party_nva#2.type#2.survey 2.party_vb#2.type#2.survey 2.sex age 1.survey 2.survey) stats(N r2_a, labels("Observations" "Adjusted-R\textsuperscript{2}") fmt(%9.0fc %9.2fc)) nonotes

eststo clear

********************************************************************************
** PROBABILITY OF BEING IN GOVERNMENT: ACCURACY
********************************************************************************

* Ordinary least squares regression models
eststo GA1: reg govt_pvda_brier i.party_pvda##i.type##i.survey i.sex age 
eststo GA2: reg govt_groen_brier i.party_groen##i.type##i.survey i.sex age
eststo GA3: reg govt_vooruit_brier i.party_vooruit##i.type##i.survey i.sex age
eststo GA4: reg govt_cdv_brier i.party_cdv##i.type##i.survey i.sex age
eststo GA5: reg govt_ovld_brier i.party_ovld##i.type##i.survey i.sex age
eststo GA6: reg govt_nva_brier i.party_nva##i.type##i.survey i.sex age
eststo GA7: reg govt_vb_brier i.party_vb##i.type##i.survey i.sex age

* Regression table
esttab GA1 GA2 GA3 GA4 GA5 GA6 GA7 using "govt_acc_models.tex", substitute({table} {table*} \begin{tabular*} \footnotesize\begin{tabular*}) wide nonumbers drop(1.party_pvda 1.party_groen 1.party_vooruit 1.party_ovld 1.party_cdv 1.party_nva 1.party_vb 1.sex 1.party_pvda#1.type 1.party_pvda#2.type 1.party_pvda#1.type#1.survey 1.party_pvda#1.type#2.survey 1.party_pvda#2.type#1.survey 1.party_pvda#2.type#2.survey 1.party_groen#1.type 1.party_groen#2.type 1.party_groen#1.type#1.survey 1.party_groen#1.type#2.survey  1.party_groen#2.type#1.survey 1.party_groen#2.type#2.survey 1.party_vooruit#1.type 1.party_vooruit#2.type 1.party_vooruit#1.type#1.survey 1.party_vooruit#1.type#2.survey 1.party_vooruit#2.type#1.survey 1.party_vooruit#2.type#2.survey 1.party_cdv#1.type 1.party_cdv#2.type 1.party_cdv#1.type#1.survey 1.party_cdv#1.type#2.survey 1.party_cdv#2.type#1.survey 1.party_cdv#2.type#2.survey 1.party_ovld#1.type 1.party_ovld#2.type 1.party_ovld#1.type#1.survey 1.party_ovld#1.type#2.survey 1.party_ovld#2.type#1.survey 1.party_ovld#2.type#2.survey 1.party_nva#1.type 1.party_nva#2.type 1.party_nva#1.type#1.survey 1.party_nva#1.type#2.survey 1.party_nva#2.type#1.survey 1.party_nva#2.type#2.survey 1.party_vb#1.type 1.party_vb#2.type 1.party_vb#1.type#1.survey 1.party_vb#1.type#2.survey 1.party_vb#2.type#1.survey 1.party_vb#2.type#2.survey 2.party_pvda#1.type#1.survey 2.party_pvda#1.type#2.survey 2.party_pvda#2.type#1.survey 2.party_groen#1.type#1.survey 2.party_groen#1.type#2.survey 2.party_groen#2.type#1.survey 2.party_vooruit#1.type#1.survey 2.party_vooruit#1.type#2.survey 2.party_vooruit#2.type#1.survey 2.party_cdv#1.type#1.survey 2.party_cdv#1.type#2.survey 2.party_cdv#2.type#1.survey 2.party_ovld#1.type#1.survey 2.party_ovld#1.type#2.survey 2.party_ovld#2.type#1.survey 2.party_nva#1.type#1.survey 2.party_nva#1.type#2.survey 2.party_nva#2.type#1.survey 2.party_vb#1.type#1.survey 2.party_vb#1.type#2.survey 2.party_vb#2.type#1.survey 1.party_pvda#2.survey 2.party_pvda#1.survey 1.party_groen#2.survey 2.party_groen#1.survey 1.party_vooruit#2.survey 2.party_vooruit#1.survey 1.party_cdv#2.survey 2.party_cdv#1.survey 1.party_ovld#2.survey 2.party_ovld#1.survey 1.party_nva#2.survey 2.party_nva#1.survey 1.party_vb#2.survey 2.party_vb#1.survey 2.party_pvda#1.type 2.party_groen#1.type 2.party_vooruit#1.type 2.party_cdv#1.type 2.party_ovld#1.type 2.party_nva#1.type 2.party_vb#1.type 1.party_pvda#1.survey 1.party_vooruit#1.survey 1.party_groen#1.survey 1.party_cdv#1.survey 1.party_ovld#1.survey 1.party_nva#1.survey 1.party_vb#1.survey 1.type#1.survey 1.type#2.survey 2.type#1.survey) refcat(2.party_pvda "\textbf{Party preference}" 1.type "\textbf{Respondents}" 2.sex "\textbf{Sociodemographics}" 1.survey "\textbf{Survey}" 2.party_pvda#2.type "\textbf{Two-way interactions I}" 2.party_pvda#2.survey "\textbf{Two-way interactions II}" 2.type#2.survey "\textbf{Two-way interactions III}" 2.party_pvda#2.type#2.survey "\textbf{Three-way interactions}", nolabel) width(\hsize) b(2) se(2) star(* 0.05) label mtitles("PVDA" "Groen" "Vooruit" "CD\&V" "Open VLD" "N-VA" "VB") interaction("$\times$") style(tex) replace booktabs varlabels(_cons "\textbf{Constant}" 1.type "\hspace{1em} Citizens (R)" 2.type "\hspace{1em} Politicians" 2.party_pvda "\hspace{1em} PVDA" 2.party_groen "\hspace{1em} Groen" 2.party_vooruit "\hspace{1em} Vooruit" 2.party_ovld "\hspace{1em} Open Vld" 2.party_cdv "\hspace{1em} CD\&V" 2.party_nva "\hspace{1em} N-VA" 2.party_vb "\hspace{1em} VB" 2.party_pvda#2.type "\hspace{1em} PVDA $\times$ Politicians" 2.party_groen#2.type "\hspace{1em} Groen $\times$ Politicians" 2.party_vooruit#2.type "\hspace{1em} Vooruit $\times$ Politicians" 2.party_ovld#2.type "\hspace{1em} Open Vld $\times$ Politicians" 2.party_cdv#2.type "\hspace{1em} CD\&V $\times$ Politicians" 2.party_nva#2.type "\hspace{1em} N-VA $\times$ Politicians" 2.party_vb#2.type "\hspace{1em} VB $\times$ Politicians" 2.sex "\hspace{1em} Male" age "\hspace{1em} Age" 1.survey "\hspace{1em} 2023 survey (R)" 2.survey "\hspace{1em} 2024 survey" 2.type#2.survey "\hspace{1em} Politicians $\times$ 2024 survey" 2.party_pvda#2.survey "\hspace{1em} PVDA $\times$ 2024 survey" 2.party_groen#2.survey "\hspace{1em} Groen $\times$ 2024 survey" 2.party_vooruit#2.survey "\hspace{1em} Vooruit $\times$ 2024 survey" 2.party_cdv#2.survey "\hspace{1em} CD\&V $\times$ 2024 survey" 2.party_ovld#2.survey "\hspace{1em} Open Vld $\times$ 2024 survey" 2.party_nva#2.survey "\hspace{1em} N-VA $\times$ 2024 survey" 2.party_vb#2.survey "\hspace{1em} VB $\times$ 2024 survey" 2.party_pvda#2.type#2.survey "\hspace{1em} PVDA $\times$ Politicians $\times$ 2024 survey" 2.party_groen#2.type#2.survey "\hspace{1em} Groen $\times$ Politicians $\times$ 2024 survey" 2.party_vooruit#2.type#2.survey "\hspace{1em} Vooruit $\times$ Politicians $\times$ 2024 survey" 2.party_cdv#2.type#2.survey "\hspace{1em} CD\&V $\times$ Politicians $\times$ 2024 survey" 2.party_ovld#2.type#2.survey "\hspace{1em} Open Vld $\times$ Politicians $\times$ 2024 survey" 2.party_nva#2.type#2.survey "\hspace{1em} N-VA $\times$ Politicians $\times$ 2024 survey" 2.party_vb#2.type#2.survey "\hspace{1em} VB $\times$ Politicians $\times$ 2024 survey") title("OLS Regression Results for Citizens' and Politicians' Government Participation Accuracy"\label{govt_acc_models}) order(1.type 2.type 2.party_pvda 2.party_groen 2.party_vooruit 2.party_cdv 2.party_ovld 2.party_nva 2.party_vb 2.party_pvda#2.type 2.party_groen#2.type 2.party_vooruit#2.type 2.party_cdv#2.type 2.party_ovld#2.type 2.party_nva#2.type 2.party_vb#2.type 2.party_pvda#2.survey 2.party_groen#2.survey 2.party_vooruit#2.survey 2.party_cdv#2.survey 2.party_ovld#2.survey 2.party_nva#2.survey 2.party_vb#2.survey 2.type#2.survey 2.party_pvda#2.type#2.survey 2.party_groen#2.type#2.survey 2.party_vooruit#2.type#2.survey 2.party_cdv#2.type#2.survey 2.party_ovld#2.type#2.survey 2.party_nva#2.type#2.survey 2.party_vb#2.type#2.survey 2.sex age 1.survey 2.survey) stats(N r2_a, labels("Observations" "Adjusted-R\textsuperscript{2}") fmt(%9.0fc %9.2fc)) nonotes

eststo clear

********************************************************************************
** MORE OR LESS SEATS: EXPECTATIONS
********************************************************************************

* Ordered logistic regression models
eststo SE1: ologit seats_pvda i.party_pvda##i.type##i.survey i.sex age 
eststo SE2: ologit seats_groen i.party_groen##i.type##i.survey i.sex age
eststo SE3: ologit seats_vooruit i.party_vooruit##i.type##i.survey i.sex age
eststo SE4: ologit seats_cdv i.party_cdv##i.type##i.survey i.sex age
eststo SE5: ologit seats_ovld i.party_ovld##i.type##i.survey i.sex age
eststo SE6: ologit seats_nva i.party_nva##i.type##i.survey i.sex age
eststo SE7: ologit seats_vb i.party_vb##i.type##i.survey i.sex age

* Regression table
esttab SE1 SE2 SE3 SE4 SE5 SE6 SE7 using "seats_exp_models.tex", substitute({table} {table*} \begin{tabular*} \footnotesize\begin{tabular*}) wide nonumbers drop(1.party_pvda 1.party_groen 1.party_vooruit 1.party_ovld 1.party_cdv 1.party_nva 1.party_vb 1.sex 1.party_pvda#1.type 1.party_pvda#2.type 1.party_pvda#1.type#1.survey 1.party_pvda#1.type#2.survey 1.party_pvda#2.type#1.survey 1.party_pvda#2.type#2.survey 1.party_groen#1.type 1.party_groen#2.type 1.party_groen#1.type#1.survey 1.party_groen#1.type#2.survey  1.party_groen#2.type#1.survey 1.party_groen#2.type#2.survey 1.party_vooruit#1.type 1.party_vooruit#2.type 1.party_vooruit#1.type#1.survey 1.party_vooruit#1.type#2.survey 1.party_vooruit#2.type#1.survey 1.party_vooruit#2.type#2.survey 1.party_cdv#1.type 1.party_cdv#2.type 1.party_cdv#1.type#1.survey 1.party_cdv#1.type#2.survey 1.party_cdv#2.type#1.survey 1.party_cdv#2.type#2.survey 1.party_ovld#1.type 1.party_ovld#2.type 1.party_ovld#1.type#1.survey 1.party_ovld#1.type#2.survey 1.party_ovld#2.type#1.survey 1.party_ovld#2.type#2.survey 1.party_nva#1.type 1.party_nva#2.type 1.party_nva#1.type#1.survey 1.party_nva#1.type#2.survey 1.party_nva#2.type#1.survey 1.party_nva#2.type#2.survey 1.party_vb#1.type 1.party_vb#2.type 1.party_vb#1.type#1.survey 1.party_vb#1.type#2.survey 1.party_vb#2.type#1.survey 1.party_vb#2.type#2.survey 2.party_pvda#1.type#1.survey 2.party_pvda#1.type#2.survey 2.party_pvda#2.type#1.survey 2.party_groen#1.type#1.survey 2.party_groen#1.type#2.survey 2.party_groen#2.type#1.survey 2.party_vooruit#1.type#1.survey 2.party_vooruit#1.type#2.survey 2.party_vooruit#2.type#1.survey 2.party_cdv#1.type#1.survey 2.party_cdv#1.type#2.survey 2.party_cdv#2.type#1.survey 2.party_ovld#1.type#1.survey 2.party_ovld#1.type#2.survey 2.party_ovld#2.type#1.survey 2.party_nva#1.type#1.survey 2.party_nva#1.type#2.survey 2.party_nva#2.type#1.survey 2.party_vb#1.type#1.survey 2.party_vb#1.type#2.survey 2.party_vb#2.type#1.survey 1.party_pvda#2.survey 2.party_pvda#1.survey 1.party_groen#2.survey 2.party_groen#1.survey 1.party_vooruit#2.survey 2.party_vooruit#1.survey 1.party_cdv#2.survey 2.party_cdv#1.survey 1.party_ovld#2.survey 2.party_ovld#1.survey 1.party_nva#2.survey 2.party_nva#1.survey 1.party_vb#2.survey 2.party_vb#1.survey 2.party_pvda#1.type 2.party_groen#1.type 2.party_vooruit#1.type 2.party_cdv#1.type 2.party_ovld#1.type 2.party_nva#1.type 2.party_vb#1.type 1.party_pvda#1.survey 1.party_vooruit#1.survey 1.party_groen#1.survey 1.party_cdv#1.survey 1.party_ovld#1.survey 1.party_nva#1.survey 1.party_vb#1.survey 1.type#1.survey 1.type#2.survey 2.type#1.survey) refcat(2.party_pvda "\textbf{Party preference}" 1.type "\textbf{Respondents}" 2.sex "\textbf{Sociodemographics}" 1.survey "\textbf{Survey}" 2.party_pvda#2.type "\textbf{Two-way interactions I}" 2.party_pvda#2.survey "\textbf{Two-way interactions II}" 2.type#2.survey "\textbf{Two-way interactions III}" 2.party_pvda#2.type#2.survey "\textbf{Three-way interactions}" cut1 "\textbf{Cut points}", nolabel) width(\hsize) b(2) se(2) star(* 0.05) label mtitles("PVDA" "Groen" "Vooruit" "CD\&V" "Open VLD" "N-VA" "VB") interaction("$\times$") style(tex) replace booktabs varlabels(_cons "\textbf{Constant}" 1.type "\hspace{1em} Citizens (R)" 2.type "\hspace{1em} Politicians" 2.party_pvda "\hspace{1em} PVDA" 2.party_groen "\hspace{1em} Groen" 2.party_vooruit "\hspace{1em} Vooruit" 2.party_ovld "\hspace{1em} Open Vld" 2.party_cdv "\hspace{1em} CD\&V" 2.party_nva "\hspace{1em} N-VA" 2.party_vb "\hspace{1em} VB" 2.party_pvda#2.type "\hspace{1em} PVDA $\times$ Politicians" 2.party_groen#2.type "\hspace{1em} Groen $\times$ Politicians" 2.party_vooruit#2.type "\hspace{1em} Vooruit $\times$ Politicians" 2.party_ovld#2.type "\hspace{1em} Open Vld $\times$ Politicians" 2.party_cdv#2.type "\hspace{1em} CD\&V $\times$ Politicians" 2.party_nva#2.type "\hspace{1em} N-VA $\times$ Politicians" 2.party_vb#2.type "\hspace{1em} VB $\times$ Politicians" 2.sex "\hspace{1em} Male" age "\hspace{1em} Age" 1.survey "\hspace{1em} 2023 survey (R)" 2.survey "\hspace{1em} 2024 survey" 2.type#2.survey "\hspace{1em} Politicians $\times$ 2024 survey" 2.party_pvda#2.survey "\hspace{1em} PVDA $\times$ 2024 survey" 2.party_groen#2.survey "\hspace{1em} Groen $\times$ 2024 survey" 2.party_vooruit#2.survey "\hspace{1em} Vooruit $\times$ 2024 survey" 2.party_cdv#2.survey "\hspace{1em} CD\&V $\times$ 2024 survey" 2.party_ovld#2.survey "\hspace{1em} Open Vld $\times$ 2024 survey" 2.party_nva#2.survey "\hspace{1em} N-VA $\times$ 2024 survey" 2.party_vb#2.survey "\hspace{1em} VB $\times$ 2024 survey" 2.party_pvda#2.type#2.survey "\hspace{1em} PVDA $\times$ Politicians $\times$ 2024 survey" 2.party_groen#2.type#2.survey "\hspace{1em} Groen $\times$ Politicians $\times$ 2024 survey" 2.party_vooruit#2.type#2.survey "\hspace{1em} Vooruit $\times$ Politicians $\times$ 2024 survey" 2.party_cdv#2.type#2.survey "\hspace{1em} CD\&V $\times$ Politicians $\times$ 2024 survey" 2.party_ovld#2.type#2.survey "\hspace{1em} Open Vld $\times$ Politicians $\times$ 2024 survey" 2.party_nva#2.type#2.survey "\hspace{1em} N-VA $\times$ Politicians $\times$ 2024 survey" 2.party_vb#2.type#2.survey "\hspace{1em} VB $\times$ Politicians $\times$ 2024 survey" cut1 "\hspace{1em} Cut point 1" cut2 "\hspace{1em} Cut point 2") title("Ordered Logistic Regression Results for Citizens' and Politicians' Expectations, Getting More or Less Seats"\label{seats_exp_models}) order(1.type 2.type 2.party_pvda 2.party_groen 2.party_vooruit 2.party_cdv 2.party_ovld 2.party_nva 2.party_vb 2.party_pvda#2.type 2.party_groen#2.type 2.party_vooruit#2.type 2.party_cdv#2.type 2.party_ovld#2.type 2.party_nva#2.type 2.party_vb#2.type 2.party_pvda#2.survey 2.party_groen#2.survey 2.party_vooruit#2.survey 2.party_cdv#2.survey 2.party_ovld#2.survey 2.party_nva#2.survey 2.party_vb#2.survey 2.type#2.survey 2.party_pvda#2.type#2.survey 2.party_groen#2.type#2.survey 2.party_vooruit#2.type#2.survey 2.party_cdv#2.type#2.survey 2.party_ovld#2.type#2.survey 2.party_nva#2.type#2.survey 2.party_vb#2.type#2.survey 2.sex age 1.survey 2.survey cut1 cut2) stats(N r2_p, labels("Observations" "Pseudo-R\textsuperscript{2}") fmt(%9.0fc %9.2fc)) nonotes

eststo clear

********************************************************************************
** MORE OR LESS SEATS: ACCURACY
********************************************************************************

* Logistic regression models
eststo SA1: logit seats_pvda_correct i.party_pvda##i.type##i.survey i.sex age 
eststo SA2: logit seats_groen_correct i.party_groen##i.type##i.survey i.sex age
eststo SA3: logit seats_vooruit_correct i.party_vooruit##i.type##i.survey i.sex age
eststo SA4: logit seats_cdv_correct i.party_cdv##i.type##i.survey i.sex age
eststo SA5: logit seats_ovld_correct i.party_ovld##i.type##i.survey i.sex age
eststo SA6: logit seats_nva_correct i.party_nva##i.type##i.survey i.sex age
eststo SA7: logit seats_vb_correct i.party_vb##i.type##i.survey i.sex age

* Regression table
esttab SA1 SA2 SA3 SA4 SA5 SA6 SA7 using "seats_acc_models.tex", substitute({table} {table*} \begin{tabular*} \footnotesize\begin{tabular*}) wide nonumbers drop(1.party_pvda 1.party_groen 1.party_vooruit 1.party_ovld 1.party_cdv 1.party_nva 1.party_vb 1.sex 1.party_pvda#1.type 1.party_pvda#2.type 1.party_pvda#1.type#1.survey 1.party_pvda#1.type#2.survey 1.party_pvda#2.type#1.survey 1.party_pvda#2.type#2.survey 1.party_groen#1.type 1.party_groen#2.type 1.party_groen#1.type#1.survey 1.party_groen#1.type#2.survey  1.party_groen#2.type#1.survey 1.party_groen#2.type#2.survey 1.party_vooruit#1.type 1.party_vooruit#2.type 1.party_vooruit#1.type#1.survey 1.party_vooruit#1.type#2.survey 1.party_vooruit#2.type#1.survey 1.party_vooruit#2.type#2.survey 1.party_cdv#1.type 1.party_cdv#2.type 1.party_cdv#1.type#1.survey 1.party_cdv#1.type#2.survey 1.party_cdv#2.type#1.survey 1.party_cdv#2.type#2.survey 1.party_ovld#1.type 1.party_ovld#2.type 1.party_ovld#1.type#1.survey 1.party_ovld#1.type#2.survey 1.party_ovld#2.type#1.survey 1.party_ovld#2.type#2.survey 1.party_nva#1.type 1.party_nva#2.type 1.party_nva#1.type#1.survey 1.party_nva#1.type#2.survey 1.party_nva#2.type#1.survey 1.party_nva#2.type#2.survey 1.party_vb#1.type 1.party_vb#2.type 1.party_vb#1.type#1.survey 1.party_vb#1.type#2.survey 1.party_vb#2.type#1.survey 1.party_vb#2.type#2.survey 2.party_pvda#1.type#1.survey 2.party_pvda#1.type#2.survey 2.party_pvda#2.type#1.survey 2.party_groen#1.type#1.survey 2.party_groen#1.type#2.survey 2.party_groen#2.type#1.survey 2.party_vooruit#1.type#1.survey 2.party_vooruit#1.type#2.survey 2.party_vooruit#2.type#1.survey 2.party_cdv#1.type#1.survey 2.party_cdv#1.type#2.survey 2.party_cdv#2.type#1.survey 2.party_ovld#1.type#1.survey 2.party_ovld#1.type#2.survey 2.party_ovld#2.type#1.survey 2.party_nva#1.type#1.survey 2.party_nva#1.type#2.survey 2.party_nva#2.type#1.survey 2.party_vb#1.type#1.survey 2.party_vb#1.type#2.survey 2.party_vb#2.type#1.survey 1.party_pvda#2.survey 2.party_pvda#1.survey 1.party_groen#2.survey 2.party_groen#1.survey 1.party_vooruit#2.survey 2.party_vooruit#1.survey 1.party_cdv#2.survey 2.party_cdv#1.survey 1.party_ovld#2.survey 2.party_ovld#1.survey 1.party_nva#2.survey 2.party_nva#1.survey 1.party_vb#2.survey 2.party_vb#1.survey 2.party_pvda#1.type 2.party_groen#1.type 2.party_vooruit#1.type 2.party_cdv#1.type 2.party_ovld#1.type 2.party_nva#1.type 2.party_vb#1.type 1.party_pvda#1.survey 1.party_vooruit#1.survey 1.party_groen#1.survey 1.party_cdv#1.survey 1.party_ovld#1.survey 1.party_nva#1.survey 1.party_vb#1.survey 1.type#1.survey 1.type#2.survey 2.type#1.survey) refcat(2.party_pvda "\textbf{Party preference}" 1.type "\textbf{Respondents}" 2.sex "\textbf{Sociodemographics}" 1.survey "\textbf{Survey}" 2.party_pvda#2.type "\textbf{Two-way interactions I}" 2.party_pvda#2.survey "\textbf{Two-way interactions II}" 2.type#2.survey "\textbf{Two-way interactions III}" 2.party_pvda#2.type#2.survey "\textbf{Three-way interactions}", nolabel) width(\hsize) b(2) se(2) star(* 0.05) label mtitles("PVDA" "Groen" "Vooruit" "CD\&V" "Open VLD" "N-VA" "VB") interaction("$\times$") style(tex) replace booktabs varlabels(_cons "\textbf{Constant}" 1.type "\hspace{1em} Citizens (R)" 2.type "\hspace{1em} Politicians" 2.party_pvda "\hspace{1em} PVDA" 2.party_groen "\hspace{1em} Groen" 2.party_vooruit "\hspace{1em} Vooruit" 2.party_ovld "\hspace{1em} Open Vld" 2.party_cdv "\hspace{1em} CD\&V" 2.party_nva "\hspace{1em} N-VA" 2.party_vb "\hspace{1em} VB" 2.party_pvda#2.type "\hspace{1em} PVDA $\times$ Politicians" 2.party_groen#2.type "\hspace{1em} Groen $\times$ Politicians" 2.party_vooruit#2.type "\hspace{1em} Vooruit $\times$ Politicians" 2.party_ovld#2.type "\hspace{1em} Open Vld $\times$ Politicians" 2.party_cdv#2.type "\hspace{1em} CD\&V $\times$ Politicians" 2.party_nva#2.type "\hspace{1em} N-VA $\times$ Politicians" 2.party_vb#2.type "\hspace{1em} VB $\times$ Politicians" 2.sex "\hspace{1em} Male" age "\hspace{1em} Age" 1.survey "\hspace{1em} 2023 survey (R)" 2.survey "\hspace{1em} 2024 survey" 2.type#2.survey "\hspace{1em} Politicians $\times$ 2024 survey" 2.party_pvda#2.survey "\hspace{1em} PVDA $\times$ 2024 survey" 2.party_groen#2.survey "\hspace{1em} Groen $\times$ 2024 survey" 2.party_vooruit#2.survey "\hspace{1em} Vooruit $\times$ 2024 survey" 2.party_cdv#2.survey "\hspace{1em} CD\&V $\times$ 2024 survey" 2.party_ovld#2.survey "\hspace{1em} Open Vld $\times$ 2024 survey" 2.party_nva#2.survey "\hspace{1em} N-VA $\times$ 2024 survey" 2.party_vb#2.survey "\hspace{1em} VB $\times$ 2024 survey" 2.party_pvda#2.type#2.survey "\hspace{1em} PVDA $\times$ Politicians $\times$ 2024 survey" 2.party_groen#2.type#2.survey "\hspace{1em} Groen $\times$ Politicians $\times$ 2024 survey" 2.party_vooruit#2.type#2.survey "\hspace{1em} Vooruit $\times$ Politicians $\times$ 2024 survey" 2.party_cdv#2.type#2.survey "\hspace{1em} CD\&V $\times$ Politicians $\times$ 2024 survey" 2.party_ovld#2.type#2.survey "\hspace{1em} Open Vld $\times$ Politicians $\times$ 2024 survey" 2.party_nva#2.type#2.survey "\hspace{1em} N-VA $\times$ Politicians $\times$ 2024 survey" 2.party_vb#2.type#2.survey "\hspace{1em} VB $\times$ Politicians $\times$ 2024 survey") title("Logistic Regression Results for Citizens' and Politicians' Seat Accuracy"\label{seats_acc_models}) order(1.type 2.type 2.party_pvda 2.party_groen 2.party_vooruit 2.party_cdv 2.party_ovld 2.party_nva 2.party_vb 2.party_pvda#2.type 2.party_groen#2.type 2.party_vooruit#2.type 2.party_cdv#2.type 2.party_ovld#2.type 2.party_nva#2.type 2.party_vb#2.type 2.party_pvda#2.survey 2.party_groen#2.survey 2.party_vooruit#2.survey 2.party_cdv#2.survey 2.party_ovld#2.survey 2.party_nva#2.survey 2.party_vb#2.survey 2.type#2.survey 2.party_pvda#2.type#2.survey 2.party_groen#2.type#2.survey 2.party_vooruit#2.type#2.survey 2.party_cdv#2.type#2.survey 2.party_ovld#2.type#2.survey 2.party_nva#2.type#2.survey 2.party_vb#2.type#2.survey 2.sex age 1.survey 2.survey) stats(N r2_p, labels("Observations" "Pseudo-R\textsuperscript{2}") fmt(%9.0fc %9.2fc)) nonotes

eststo clear

********************************************************************************
** MORE OR LESS SEATS: ACCURACY (0-7 SCALE)
********************************************************************************

gen seats_accuracy2 = seats_accuracy - 1

* Ordinary least squares regression models
eststo SA: reg seats_accuracy2 i.seats_winner##i.type##i.survey i.sex age 

* Regression table
esttab SA using "seats_acc_model.tex", substitute({table} {table*} \begin{tabular*} \footnotesize\begin{tabular*}) wide nonumbers drop(0.seats_winner 1.sex 0.seats_winner#1.type 0.seats_winner#2.type 0.seats_winner#1.type#1.survey 0.seats_winner#1.type#2.survey 0.seats_winner#2.type#1.survey 0.seats_winner#2.type#2.survey 1.seats_winner#1.type#1.survey 1.seats_winner#1.type#2.survey 1.seats_winner#2.type#1.survey 0.seats_winner#2.survey 1.seats_winner#1.survey 1.seats_winner#1.type 0.seats_winner#1.survey 1.type#1.survey 1.type#2.survey 2.type#1.survey) refcat(1.seats_winner "\textbf{Party preference}" 1.type "\textbf{Respondents}" 2.sex "\textbf{Sociodemographics}" 1.survey "\textbf{Survey}" 1.seats_winner#2.type "\textbf{Two-way interactions I}" 1.seats_winner#2.survey "\textbf{Two-way interactions II}" 2.type#2.survey "\textbf{Two-way interactions III}" 1.seats_winner#2.type#2.survey "\textbf{Three-way interactions}", nolabel) width(\hsize) b(2) se(2) star(* 0.05) label mtitles("") interaction("$\times$") style(tex) replace booktabs varlabels(_cons "\textbf{Constant}" 1.type "\hspace{1em} Citizens (R)" 2.type "\hspace{1em} Politicians" 1.seats_winner "\hspace{1em} Winner" 1.seats_winner#2.type "\hspace{1em} Winner $\times$ Politicians" 2.sex "\hspace{1em} Male" age "\hspace{1em} Age" 1.survey "\hspace{1em} 2023 survey (R)" 2.survey "\hspace{1em} 2024 survey" 2.type#2.survey "\hspace{1em} Politicians $\times$ 2024 survey" 1.seats_winner#2.survey "\hspace{1em} Winner $\times$ 2024 survey" 1.seats_winner#2.type#2.survey "\hspace{1em} Winner $\times$ Politicians $\times$ 2024 survey") title("OLS Regression Results for Citizens' and Politicians' Seat Accuracy"\label{seats_acc_model}) order(1.type 2.type 1.seats_winner 1.seats_winner#2.type 1.seats_winner#2.survey 2.type#2.survey 1.seats_winner#2.type#2.survey 2.sex age 1.survey 2.survey) stats(N r2_a, labels("Observations" "Adjusted-R\textsuperscript{2}") fmt(%9.0fc %9.2fc)) nonotes

eststo clear


********************************************************************************
** MORE OR LESS SEATS: EXPECTATIONS -- SECOND DIFFERENCES
********************************************************************************

local parties pvda groen vooruit cdv ovld nva vb

foreach party of local parties {
    di "Running analysis for `party'"

    * STEP 1: Ordered Logit Model
    ologit seats_`party' i.party_`party'##i.type##i.survey i.sex age

    * STEP 2: Predicted probabilities
    margins, over(party_`party') at(type=(1 2) survey=(1 2)) post

    * STEP 3: Extract predicted probabilities
    mlincom, clear

    forvalues i = 1/24 {
        * Define row labels based on index
        local outcome = cond(`i' <= 8, "Less", cond(`i' <= 16, "Same", "More"))
        local grp = cond(mod(`i'-1, 2) == 0, "Other", "`party'")
        local tp = cond(mod(`i'-1, 4) < 2, "C", "P")
        local sv = cond(inrange(`i',1,4) | inrange(`i',9,12) | inrange(`i',17,20), "S23", "S24")

        qui mlincom `i', stat(est se p) add rowname("`outcome'_`tp'_`sv'_`grp'")
    }

    * STEP 4: Calculate Average Marginal Effects (AMEs)
    local ame_pairs "2 1 6 5 4 3 8 7 10 9 14 13 12 11 16 15 18 17 22 21 20 19 24 23"
    local ame_labels "Less_C_S23 Less_C_S24 Less_P_S23 Less_P_S24 Same_C_S23 Same_C_S24 Same_P_S23 Same_P_S24 More_C_S23 More_C_S24 More_P_S23 More_P_S24"

    local j = 1
    foreach label of local ame_labels {
        local idx1 = word("`ame_pairs'", `=`j'*2 - 1')
        local idx2 = word("`ame_pairs'", `=`j'*2')
        qui mlincom `idx1' - `idx2', stat(est se p) add rowname("`label'_AME_`party'")
        local ++j
    }

    * STEP 5: Test Second Differences (Difference-in-Differences of AMEs)
    qui mlincom (2 - 1) - (4 - 3), stat(est se p) add rowname("L_2_`party'_S23")
    qui mlincom (6 - 5) - (8 - 7), stat(est se p) add rowname("L_2_`party'_S24")
    qui mlincom (10 - 9) - (12 - 11), stat(est se p) add rowname("S_2_`party'_S23")
    qui mlincom (14 - 13) - (16 - 15), stat(est se p) add rowname("S_2_`party'_S24")
    qui mlincom (18 - 17) - (20 - 19), stat(est se p) add rowname("M_2_`party'_S23")
    qui mlincom (22 - 21) - (24 - 23), stat(est se p) add rowname("M_2_`party'_S24")

    * STEP 6: Test Third Differences (Changes over Surveys)
    qui mlincom ((6 - 5) - (8 - 7)) - ((2 - 1) - (4 - 3)), stat(est se p) add rowname("Less_3_`party'")
    qui mlincom ((14 - 13) - (16 - 15)) - ((10 - 9) - (12 - 11)), stat(est se p) add rowname("Same_3_`party'")
    qui mlincom ((22 - 21) - (24 - 23)) - ((18 - 17) - (20 - 19)), stat(est se p) add rowname("More_3_`party'")

    * STEP 7: Display results with a title
    mlincom, stat(est se p) title("AMEs and Tests for Party Preference (`party')")
}

********************************************************************************
** MORE OR LESS SEATS: ACCURACY -- SECOND DIFFERENCES
********************************************************************************

local parties pvda groen vooruit cdv ovld nva vb

foreach party of local parties {
    di "=============================================="
    di ">>> Running analysis for `party'"
    di "=============================================="

    * Step 0: Check that needed variables exist
    cap confirm variable seats_`party'_correct
    if _rc {
        di as error ">>> Variable seats_`party'_correct does NOT exist. Skipping."
        continue
    }

    cap confirm variable party_`party'
    if _rc {
        di as error ">>> Variable party_`party' does NOT exist. Skipping."
        continue
    }

    * STEP 1: Binary Logistic Regression
    cap logit seats_`party'_correct i.party_`party'##i.type##i.survey i.sex age
    if _rc {
        di as error ">>> Model failed for `party' (logit). Skipping."
        continue
    }

    * STEP 2: Predicted probabilities
    cap margins, over(party_`party') at(type=(1 2) survey=(1 2)) post
    if _rc {
        di as error ">>> Margins failed for `party'. Skipping."
        continue
    }

    * STEP 3: Extract predicted probabilities
    mlincom, clear

    forvalues i = 1/8 {
        * Assign group labels
        local grp = cond(mod(`i'-1, 2) == 0, "Other", "`party'")
        local tp = cond(mod(`i'-1, 4) < 2, "C", "P")
        local sv = cond(`i' <= 4, "S23", "S24")

        cap qui mlincom `i', stat(est se p) add rowname("Prob_`tp'_`sv'_`grp'")
    }

    * STEP 4: Average Marginal Effects (AMEs)
    local ame_pairs "2 1 6 5 4 3 8 7"
    local ame_labels "AME_C_S23 AME_C_S24 AME_P_S23 AME_P_S24"

    local j = 1
    foreach label of local ame_labels {
        local idx1 = word("`ame_pairs'", `=`j'*2 - 1')
        local idx2 = word("`ame_pairs'", `=`j'*2')
        cap qui mlincom `idx1' - `idx2', stat(est se p) add rowname("`label'_`party'")
        local ++j
    }

    * STEP 5: Second Differences (Difference-in-Differences)
    cap qui mlincom (2 - 1) - (4 - 3), stat(est se p) add rowname("2ndDiff_`party'_S23")
    cap qui mlincom (6 - 5) - (8 - 7), stat(est se p) add rowname("2ndDiff_`party'_S24")

    * STEP 6: Third Difference (Change over Surveys)
    cap qui mlincom ((6 - 5) - (8 - 7)) - ((2 - 1) - (4 - 3)), stat(est se p) add rowname("3rdDiff_`party'")

    * STEP 7: Display results with title
    mlincom, stat(est se p) title("AMEs and Differences for Party Preference (`party')")
}